package com.ruoyi.laiwu.controller;


import cn.dev33.satoken.annotation.SaIgnore;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.laiwu.domain.vo.LwAlarmVo;
import com.ruoyi.laiwu.service.ILwAlarmService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("fireAlarm")
@SaIgnore
@Slf4j
@RequiredArgsConstructor
public class LwAlarmController {

    private final ILwAlarmService iLwAlarmService;


    /**
     * 按照报警等级分组查看
     * @return
     */
    @PostMapping("listGroupByGrade")
    public R<List<Map<String,Object>>> listGroupByGrade(){
        return R.ok(iLwAlarmService.listGroupByGrade());
    }


    /**
     * 按照报警来源分组查看
     * @return
     */
    @PostMapping("listGroupBySourceType")
    public R<List<Map<String,Object>>> listGroupBySourceType(){
        return R.ok(iLwAlarmService.listGroupBySourceType());


    }


    /**
     * 根据报警来源查看列表
     * @param sourceType
     * @return
     */
    @GetMapping("listBySourceType")
    public R<List<LwAlarmVo>> listBySourceType(String sourceType){
        return R.ok(iLwAlarmService.listBySourceType(sourceType));
    }


    /**
     * 根据等级查询列表
     * @param grade
     * @return
     */
    @GetMapping("listByGrade")
    public R<List<LwAlarmVo>> listByGrade(String grade){
        return R.ok(iLwAlarmService.listByGrade(grade));
    }


    /**
     * 查询报警总数
     * @return
     */
    @PostMapping("listAllCount")
    public R<Long> listAllCount(){
        return R.ok(iLwAlarmService.listAllCount());
    }


    /**
     * 根据id查询报警详情
     * @param id
     * @return
     */
    @GetMapping("queryById")
    public R<LwAlarmVo> queryById(Long id){
        return R.ok(iLwAlarmService.queryById(id));
    }


    @GetMapping("queryInfo7_day")
    public R<List<LwAlarmVo>> queryInfo7_day(){
        return R.ok(iLwAlarmService.queryInfo7_day());
    }

    /**
     * 查询七天内数量
     * @return
     */
    @PostMapping("countBy_7_Day")
    public R<List<Map<String, Object>>>   countBy_7_Day(){
        return R.ok(iLwAlarmService.countBy_7_Day());
    }











}
